package cake
{
	import flash.events.EventDispatcher;
	import flash.events.Event;
		
	public class Dispatcher extends EventDispatcher
	{
		private static var instance:Dispatcher;
		public function Dispatcher(callee:Function){
			if(callee != Dispatcher.getInstance){
				throw new Error('Dispatcher is a singelton, please use getInstance()');
			}
			trace('dispatcher made');
			
		}
		public static function getInstance():Dispatcher{
			if(instance ==  null){
				instance = new Dispatcher(arguments.callee);
			}
			return instance;
		}
		public override function dispatchEvent(event:Event):Boolean{
			trace('dispatching event');
			super.dispatchEvent(event);
			return true;
		}
	}
}